# ---- revision log handling ----------------------------

import os, string
import vcs
from logParser import * 

TEST	= 0

class Rlog(Log):
	REV_SEP     = '-'*28
	REV_SEPn    = REV_SEP + NL
	END_OF_LOG  = '='*77
	END_OF_LOGn = END_OF_LOG + NL
	SKIP_TAGS	= { }
	CMD		= 'rlog -V5 %s'
 
	def parse_history(self):
		if self.revisions:
			return
		maxi = len(self.history)-1
		if maxi < 2:
			return
		i = 0
		while i<=maxi:
			if self.history[i] != self.REV_SEP:
				break
			i=i+1
			fields = string.split(self.history[i])
			rev = Revision(fields[1])
			if len(fields) > 2:
				rev.locked_by = fields[4]
			i=i+1
			fields = string.split(self.history[i],'  ')
			for field in fields:
				[tag, value] = string.split(field, ': ')
				setattr(rev,tag,value)
			i=i+1
			if self.history[i][:9] == 'branches:':
				rev.branches = string.strip(self.history[i][10:])
				i=i+1
			msglist = []
			while i<=maxi and self.history[i] != self.REV_SEP:
				msglist.append(self.history[i])
				i=i+1
			rev.log_message = string.join(msglist, NL)
			self.revisions.append(rev)
 
	def head_rev(self):
		return self.head
	def _work_file(self):
		return self.working_file
	def _lockers_list(self):
		return string.split(self.locks, NL)[1:]
	def lockers(self):
		return string.join(self._lockers_list())
	def symbolstr(self):
		return self.symbolic_names
	def symbollist(self):
		return string.split(self.symbolic_names, NL)

